import mutations from './mutations'
import actions from './actions'

// 声明一个store实例 => 默认暴露该实例
export default {
	// state管理数据(状态)
	state: {
		x: 1,
	},
	getters: {
		doubleX: function (state) {
			return state.x * 2;
		},
		tripleX: function (state) {
			return state.x * 3;
		},
		// 子模块的getters,除了可以访问自身的state,getters,还可以访问根store的state,getters => rootState,rootGetters
		// 生成一个计算属性  计算 x 和 a的和
		xAddA: function (state,getters,rootState,rootGetters) {
			console.log("xAddA");
			console.log("state",state);
			console.log("getters",getters);
			console.log("rootState",rootState);
			console.log("rootGetters",rootGetters);
			return state.x + rootState.a;
		},
		

	},
	mutations: mutations,
	actions:actions ,
}
